package com.peanut.controller;

import com.peanut.common.Result;
import com.peanut.domain.vo.TabItemVO;
import com.peanut.service.TabItemService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Scanner;

/**注释
 * @author
 * 定义加addition、减subtration、乘multiplication、除division等方法分别对两个整数变量执行加、减、乘、除的运算
 */
@RestController
@RequestMapping("calculatorController")
public class CalculatorController {

    @Resource
    private TabItemService itemService;

    public Result calculator(Long itemId){
        TabItemVO item = itemService.getItemByID(itemId);
        //TODO 需求没理解
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入数字");
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int add = addition( a, b);
        int sub = subtration(a, b);
        int mul = multiplication(a, b);
        int div = division(a, b);

        //输出结果
        System.out.println("两个数的和为："+add);
        System.out.println("两个数的差为："+sub);
        System.out.println("两个数的乘积："+mul);
        System.out.println("两个数相除为："+div);

        return Result.ERROR();
    }

    public static int addition(int n1,int n2){  //定义求和方法
        return n1+n2;
    }

    public static int subtration(int n1,int n2){    //定义减法方法
        return n1-n2;
    }

    public static int multiplication(int n1,int n2){    //定义乘积方法
        return n1*n2;
    }

    public static int division(int n1,int n2){  //定义相除方法
        int c=n1/n2;
        int d=n1%n2; //不能同时返回两个值
        return c;
    }

}
